﻿#include "GameRole.h"
#include <memory>
#include "Originator.h"
#include "Caretaker.h"
#include "RoleStateCaretaker.h"

using namespace std;

int main(int argc, char *argv[])
{
    //大战Boss前
    shared_ptr<GameRole> lixiaoyao(new GameRole());
    lixiaoyao->getInitState();
    lixiaoyao->stateDisplay();

    //保存进度
    shared_ptr<RoleStateCaretaker> stateAdmin(new RoleStateCaretaker());
    stateAdmin->setMemento(lixiaoyao->saveState());

    //大战Boss时，损耗严重
    lixiaoyao->fight();
    lixiaoyao->stateDisplay();

    //恢复之前状态
    lixiaoyao->recoveryState(stateAdmin->getMemento());

    lixiaoyao->stateDisplay();

    /*
    shared_ptr<Originator> o(new Originator());
    o->setState("On");
    o->show();

    shared_ptr<Caretaker> c(new Caretaker());
    c->setMemento(o->CreateMemento());

    o->setState("Off");
    o->show();

    o->setMemento(c->getMemento());
    o->show();
    */

    /*
    //大战Boss前
    shared_ptr<GameRole> lixiaoyao(new GameRole());
    lixiaoyao->getInitState();
    lixiaoyao->stateDisplay();

    //保存进度
    shared_ptr<GameRole> backup(new GameRole());
    backup->setHp(lixiaoyao->getHp());
    backup->setAtk(lixiaoyao->getAtk());
    backup->setDef(lixiaoyao->getDef());

    //大战Boss时，损耗严重
    lixiaoyao->fight();
    lixiaoyao->stateDisplay();

    //恢复之前状态
    lixiaoyao->setHp(backup->getHp());
    lixiaoyao->setAtk(backup->getAtk());
    lixiaoyao->setDef(backup->getDef());

    lixiaoyao->stateDisplay();
    */

    return 0;
}
